package genetic;

public class F1Individual extends Individual {
	
	public F1Individual() {
		x = new double[2];
	}
	
	public Double f1(){
		return 100.0*Math.pow(x[0]*x[0]-x[1],2)+Math.pow(1-x[0],2);
	}
	
	//Quando mais proximo de zero, melhor
	@Override
	public Double fitness() {
		return Math.abs(f1());
	}
	
	@Override
	public void normalize() {
		for (int i = 0; i < x.length;i++) {
			x[i] = Math.max(Math.min(x[i],2.048),-2.048);
		}
	}
	
	@Override
	public String toString() {
		return ((Double)x[0]).toString() + " " + ((Double)x[1]).toString() + " " + fitness().toString(); 
	}

}
